<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>商店进出货管理系统</title>
    <style>
        body {
            font-family: 'Open Sans', sans-serif;
            margin: 0;
            display: flex;
            background-color: #f9f9f9;
        }

        .sidebar {
            width: 200px;
            background-color: #333;
            color: white;
            padding-top: 20px;
        }

        .sidebar button {
            display: block;
            width: 100%;
            padding: 15px;
            text-align: left;
            background-color: transparent;
            border: none;
            color: white;
            cursor: pointer;
            transition: background-color 0.3s;
        }

        .sidebar button:hover {
            background-color: #555;
        }

        .sidebar button.active {
            background-color: #777;
        }

        .main-content {
            flex: 1;
            padding: 20px;
        }

        .tab-content {
            display: none;
            background-color: white;
            padding: 20px;
            border-radius: 5px;
            box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
        }

        table {
            width: 100%;
            border-collapse: collapse;
            margin-top: 20px;
        }

        th,
        td {
            border: 1px solid #ddd;
            padding: 10px;
            text-align: left;
        }

        th {
            background-color: #f0f0f0;
        }

        button {
            padding: 8px 15px;
            border: none;
            border-radius: 3px;
            cursor: pointer;
            transition: background-color 0.3s;
        }

        .add-btn {
            background-color: #28a745;
            color: white;
        }

        .add-btn:hover {
            background-color: #218838;
        }

        .edit-btn {
            background-color: #ffc107;
            color: white;
        }

        .edit-btn:hover {
            background-color: #e0a800;
        }

        .delete-btn {
            background-color: #dc3545;
            color: white;
        }

        .delete-btn:hover {
            background-color: #c82333;
        }

        /* 模态框样式 */
        .modal {
            display: none;
            position: fixed;
            z-index: 1;
            left: 0;
            top: 0;
            width: 100%;
            height: 100%;
            overflow: auto;
            background-color: rgba(0, 0, 0, 0.4);
        }

        .modal-content {
            background-color: #fefefe;
            margin: 15% auto;
            padding: 20px;
            border: 1px solid #888;
            width: 30%;
            border-radius: 5px;
        }

        .close {
            color: #aaa;
            float: right;
            font-size: 28px;
            font-weight: bold;
        }

        .close:hover,
        .close:focus {
            color: black;
            text-decoration: none;
            cursor: pointer;
        }

        /* 搜索框样式 */
        .search-input {
            padding: 8px;
            margin-right: 10px;
            border: 1px solid #ddd;
            border-radius: 3px;
        }
    </style>
</head>

<body>
    <div class="sidebar">
        <button class="tablinks" onclick="openTab(event, 'Home')">首页</button>
        <button class="tablinks" onclick="openTab(event, 'GoodsManagement')">商品信息管理</button>
        <button class="tablinks" onclick="openTab(event, 'IncomingManagement')">进货信息管理</button>
        <button class="tablinks" onclick="openTab(event, 'OutgoingManagement')">出货信息管理</button>
        <button class="tablinks" onclick="openTab(event, 'SupplierManagement')">供应商信息管理</button>
        <button class="tablinks" onclick="openTab(event, 'Statistics')">数据统计</button>
    </div>
    <div class="main-content">
        <div id="Home" class="tab-content">
            <h2>首页</h2>
            <p>欢迎使用商店进出货管理系统，您可以通过左侧导航栏选择不同的功能模块进行操作。</p>
        </div>
        <div id="GoodsManagement" class="tab-content">
            <h2>商品信息管理</h2>
            <input type="text" class="search-input" id="goodsSearch" placeholder="搜索商品名称" oninput="searchGoods()">
            <button class="add-btn" onclick="openAddGoodsModal()">添加商品</button>
            <table id="goodsTable">
                <thead>
                    <tr>
                        <th>商品名称</th>
                        <th>商品型号</th>
                        <th>库存数量</th>
                        <th>操作</th>
                    </tr>
                </thead>
                <tbody></tbody>
            </table>
        </div>
        <div id="IncomingManagement" class="tab-content">
            <h2>进货信息管理</h2>
            <input type="text" class="search-input" id="incomingSearch" placeholder="搜索商品名称" oninput="searchIncoming()">
            <button class="add-btn" onclick="openAddIncomingModal()">添加进货记录</button>
            <table id="incomingTable">
                <thead>
                    <tr>
                        <th>商品名称</th>
                        <th>进货数量</th>
                        <th>进货时间</th>
                        <th>供应商</th>
                        <th>操作</th>
                    </tr>
                </thead>
                <tbody></tbody>
            </table>
        </div>
        <div id="OutgoingManagement" class="tab-content">
            <h2>出货信息管理</h2>
            <input type="text" class="search-input" id="outgoingSearch" placeholder="搜索商品名称" oninput="searchOutgoing()">
            <button class="add-btn" onclick="openAddOutgoingModal()">添加出货记录</button>
            <table id="outgoingTable">
                <thead>
                    <tr>
                        <th>商品名称</th>
                        <th>出货数量</th>
                        <th>出货时间</th>
                        <th>客户</th>
                        <th>操作</th>
                    </tr>
                </thead>
                <tbody></tbody>
            </table>
        </div>
        <div id="SupplierManagement" class="tab-content">
            <h2>供应商信息管理</h2>
            <input type="text" class="search-input" id="supplierSearch" placeholder="搜索供应商名称" oninput="searchSupplier()">
            <button class="add-btn" onclick="openAddSupplierModal()">添加供应商</button>
            <table id="supplierTable">
                <thead>
                    <tr>
                        <th>供应商名称</th>
                        <th>联系方式</th>
                        <th>操作</th>
                    </tr>
                </thead>
                <tbody></tbody>
            </table>
        </div>
        <div id="Statistics" class="tab-content">
            <h2>数据统计</h2>
            <p>商品总数: <span id="goodsCount">0</span></p>
            <p>进货记录总数: <span id="incomingCount">0</span></p>
            <p>出货记录总数: <span id="outgoingCount">0</span></p>
            <p>供应商总数: <span id="supplierCount">0</span></p>
        </div>
    </div>

    <!-- 商品添加/编辑模态框 -->
    <div id="goodsModal" class="modal">
        <div class="modal-content">
            <span class="close" onclick="closeGoodsModal()">&times;</span>
            <h2 id="goodsModalTitle">添加商品</h2>
            <label for="goodsName">商品名称:</label>
            <input type="text" id="goodsName" required><br>
            <label for="goodsModel">商品型号:</label>
            <input type="text" id="goodsModel" required><br>
            <label for="goodsQuantity">库存数量:</label>
            <input type="number" id="goodsQuantity" required><br>
            <button onclick="saveGoods()">保存</button>
        </div>
    </div>

    <!-- 进货添加/编辑模态框 -->
    <div id="incomingModal" class="modal">
        <div class="modal-content">
            <span class="close" onclick="closeIncomingModal()">&times;</span>
            <h2 id="incomingModalTitle">添加进货记录</h2>
            <label for="incomingGoodsName">商品名称:</label>
            <input type="text" id="incomingGoodsName" required><br>
            <label for="incomingQuantity">进货数量:</label>
            <input type="number" id="incomingQuantity" required><br>
            <label for="incomingTime">进货时间:</label>
            <input type="date" id="incomingTime" required><br>
            <label for="incomingSupplier">供应商:</label>
            <input type="text" id="incomingSupplier" required><br>
            <button onclick="saveIncoming()">保存</button>
        </div>
    </div>

    <!-- 出货添加/编辑模态框 -->
    <div id="outgoingModal" class="modal">
        <div class="modal-content">
            <span class="close" onclick="closeOutgoingModal()">&times;</span>
            <h2 id="outgoingModalTitle">添加出货记录</h2>
            <label for="outgoingGoodsName">商品名称:</label>
            <input type="text" id="outgoingGoodsName" required><br>
            <label for="outgoingQuantity">出货数量:</label>
            <input type="number" id="outgoingQuantity" required><br>
            <label for="outgoingTime">出货时间:</label>
            <input type="date" id="outgoingTime" required><br>
            <label for="outgoingCustomer">客户:</label>
            <input type="text" id="outgoingCustomer" required><br>
            <button onclick="saveOutgoing()">保存</button>
        </div>
    </div>

    <!-- 供应商添加/编辑模态框 -->
    <div id="supplierModal" class="modal">
        <div class="modal-content">
            <span class="close" onclick="closeSupplierModal()">&times;</span>
            <h2 id="supplierModalTitle">添加供应商</h2>
            <label for="supplierName">供应商名称:</label>
            <input type="text" id="supplierName" required><br>
            <label for="supplierContact">联系方式:</label>
            <input type="text" id="supplierContact" required><br>
            <button onclick="saveSupplier()">保存</button>
        </div>
    </div>

    <script>
        let currentGoodsIndex = null;
        let currentIncomingIndex = null;
        let currentOutgoingIndex = null;
        let currentSupplierIndex = null;

        // 初始化表格
        function initTables() {
            // 商品管理
            let goods = JSON.parse(localStorage.getItem('goods')) || [
                { name: '洗发水', model: '经典款', quantity: 50 },
                { name: '沐浴露', model: '滋润型', quantity: 40 },
                { name: '牙膏', model: '美白款', quantity: 60 },
                { name: '牙刷', model: '软毛', quantity: 80 },
                { name: '毛巾', model: '纯棉', quantity: 30 },
                { name: '香皂', model: '玫瑰味', quantity: 70 },
                { name: '洗衣粉', model: '强力去污', quantity: 20 },
                { name: '洗洁精', model: '柠檬味', quantity: 45 },
                { name: '卫生纸', model: '加厚', quantity: 90 },
                { name: '洗衣液', model: '薰衣草味', quantity: 35 }
            ];
            localStorage.setItem('goods', JSON.stringify(goods));
            let goodsTable = document.getElementById('goodsTable').getElementsByTagName('tbody')[0];
            goodsTable.innerHTML = '';
            goods.forEach((good, index) => {
                let row = goodsTable.insertRow();
                let cell1 = row.insertCell(0);
                let cell2 = row.insertCell(1);
                let cell3 = row.insertCell(2);
                let cell4 = row.insertCell(3);
                cell1.innerHTML = good.name;
                cell2.innerHTML = good.model;
                cell3.innerHTML = good.quantity;
                cell4.innerHTML = `<button class="edit-btn" onclick="openEditGoodsModal(${index})">编辑</button><button class="delete-btn" onclick="deleteGoods(${index})">删除</button>`;
            });

            // 进货管理
            let incoming = JSON.parse(localStorage.getItem('incoming')) || [
                { goodsName: '洗发水', quantity: 20, time: '2025-03-10', supplier: '供应商 A' },
                { goodsName: '沐浴露', quantity: 15, time: '2025-03-12', supplier: '供应商 B' },
                { goodsName: '牙膏', quantity: 25, time: '2025-03-14', supplier: '供应商 C' },
                { goodsName: '牙刷', quantity: 30, time: '2025-03-16', supplier: '供应商 D' },
                { goodsName: '毛巾', quantity: 10, time: '2025-03-18', supplier: '供应商 E' },
                { goodsName: '香皂', quantity: 18, time: '2025-03-20', supplier: '供应商 F' },
                { goodsName: '洗衣粉', quantity: 8, time: '2025-03-22', supplier: '供应商 G' },
                { goodsName: '洗洁精', quantity: 12, time: '2025-03-24', supplier: '供应商 H' },
                { goodsName: '卫生纸', quantity: 35, time: '2025-03-26', supplier: '供应商 I' },
                { goodsName: '洗衣液', quantity: 16, time: '2025-03-28', supplier: '供应商 J' }
            ];
            localStorage.setItem('incoming', JSON.stringify(incoming));
            let incomingTable = document.getElementById('incomingTable').getElementsByTagName('tbody')[0];
            incomingTable.innerHTML = '';
            incoming.forEach((record, index) => {
                let row = incomingTable.insertRow();
                let cell1 = row.insertCell(0);
                let cell2 = row.insertCell(1);
                let cell3 = row.insertCell(2);
                let cell4 = row.insertCell(3);
                let cell5 = row.insertCell(4);
                cell1.innerHTML = record.goodsName;
                cell2.innerHTML = record.quantity;
                cell3.innerHTML = record.time;
                cell4.innerHTML = record.supplier;
                cell5.innerHTML = `<button class="edit-btn" onclick="openEditIncomingModal(${index})">编辑</button><button class="delete-btn" onclick="deleteIncoming(${index})">删除</button>`;
            });

            // 出货管理
            let outgoing = JSON.parse(localStorage.getItem('outgoing')) || [
                { goodsName: '洗发水', quantity: 10, time: '2025-03-11', customer: '客户 A' },
                { goodsName: '沐浴露', quantity: 8, time: '2025-03-13', customer: '客户 B' },
                { goodsName: '牙膏', quantity: 12, time: '2025-03-15', customer: '客户 C' },
                { goodsName: '牙刷', quantity: 15, time: '2025-03-17', customer: '客户 D' },
                { goodsName: '毛巾', quantity: 5, time: '2025-03-19', customer: '客户 E' },
                { goodsName: '香皂', quantity: 9, time: '2025-03-21', customer: '客户 F' },
                { goodsName: '洗衣粉', quantity: 4, time: '2025-03-23', customer: '客户 G' },
                { goodsName: '洗洁精', quantity: 6, time: '2025-03-25', customer: '客户 H' },
                { goodsName: '卫生纸', quantity: 18, time: '2025-03-27', customer: '客户 I' },
                { goodsName: '洗衣液', quantity: 8, time: '2025-03-29', customer: '客户 J' }
            ];
            localStorage.setItem('outgoing', JSON.stringify(outgoing));
            let outgoingTable = document.getElementById('outgoingTable').getElementsByTagName('tbody')[0];
            outgoingTable.innerHTML = '';
            outgoing.forEach((record, index) => {
                let row = outgoingTable.insertRow();
                let cell1 = row.insertCell(0);
                let cell2 = row.insertCell(1);
                let cell3 = row.insertCell(2);
                let cell4 = row.insertCell(3);
                let cell5 = row.insertCell(4);
                cell1.innerHTML = record.goodsName;
                cell2.innerHTML = record.quantity;
                cell3.innerHTML = record.time;
                cell4.innerHTML = record.customer;
                cell5.innerHTML = `<button class="edit-btn" onclick="openEditOutgoingModal(${index})">编辑</button><button class="delete-btn" onclick="deleteOutgoing(${index})">删除</button>`;
            });

            // 供应商管理
            let suppliers = JSON.parse(localStorage.getItem('suppliers')) || [
                { name: '供应商 A', contact: '13800138000' },
                { name: '供应商 B', contact: '13900139000' },
                { name: '供应商 C', contact: '13700137000' },
                { name: '供应商 D', contact: '13600136000' },
                { name: '供应商 E', contact: '13500135000' },
                { name: '供应商 F', contact: '13400134000' },
                { name: '供应商 G', contact: '13300133000' },
                { name: '供应商 H', contact: '13200132000' },
                { name: '供应商 I', contact: '13100131000' },
                { name: '供应商 J', contact: '13000130000' }
            ];
            localStorage.setItem('suppliers', JSON.stringify(suppliers));
            let supplierTable = document.getElementById('supplierTable').getElementsByTagName('tbody')[0];
            supplierTable.innerHTML = '';
            suppliers.forEach((supplier, index) => {
                let row = supplierTable.insertRow();
                let cell1 = row.insertCell(0);
                let cell2 = row.insertCell(1);
                let cell3 = row.insertCell(2);
                cell1.innerHTML = supplier.name;
                cell2.innerHTML = supplier.contact;
                cell3.innerHTML = `<button class="edit-btn" onclick="openEditSupplierModal(${index})">编辑</button><button class="delete-btn" onclick="deleteSupplier(${index})">删除</button>`;
            });

            // 更新数据统计
            document.getElementById('goodsCount').textContent = goods.length;
            document.getElementById('incomingCount').textContent = incoming.length;
            document.getElementById('outgoingCount').textContent = outgoing.length;
            document.getElementById('supplierCount').textContent = suppliers.length;
        }

        // 打开 tab 页面
        function openTab(evt, tabName) {
            let i, tabcontent, tablinks;
            tabcontent = document.getElementsByClassName('tab-content');
            for (i = 0; i < tabcontent.length; i++) {
                tabcontent[i].style.display = 'none';
            }
            tablinks = document.getElementsByClassName('tablinks');
            for (i = 0; i < tablinks.length; i++) {
                tablinks[i].className = tablinks[i].className.replace(' active', '');
            }
            document.getElementById(tabName).style.display = 'block';
            evt.currentTarget.className += ' active';
        }

        // 商品管理
        function openAddGoodsModal() {
            currentGoodsIndex = null;
            document.getElementById('goodsModalTitle').textContent = '添加商品';
            document.getElementById('goodsName').value = '';
            document.getElementById('goodsModel').value = '';
            document.getElementById('goodsQuantity').value = '';
            document.getElementById('goodsModal').style.display = 'block';
        }

        function openEditGoodsModal(index) {
            currentGoodsIndex = index;
            let goods = JSON.parse(localStorage.getItem('goods'));
            let good = goods[index];
            document.getElementById('goodsModalTitle').textContent = '编辑商品';
            document.getElementById('goodsName').value = good.name;
            document.getElementById('goodsModel').value = good.model;
            document.getElementById('goodsQuantity').value = good.quantity;
            document.getElementById('goodsModal').style.display = 'block';
        }

        function closeGoodsModal() {
            document.getElementById('goodsModal').style.display = 'none';
        }

        function saveGoods() {
            let goods = JSON.parse(localStorage.getItem('goods')) || [];
            let name = document.getElementById('goodsName').value;
            let model = document.getElementById('goodsModel').value;
            let quantity = parseInt(document.getElementById('goodsQuantity').value);
            if (currentGoodsIndex === null) {
                goods.push({ name, model, quantity });
            } else {
                goods[currentGoodsIndex] = { name, model, quantity };
            }
            localStorage.setItem('goods', JSON.stringify(goods));
            initTables();
            closeGoodsModal();
        }

        function deleteGoods(index) {
            let goods = JSON.parse(localStorage.getItem('goods')) || [];
            goods.splice(index, 1);
            localStorage.setItem('goods', JSON.stringify(goods));
            initTables();
        }

        // 进货管理
        function openAddIncomingModal() {
            currentIncomingIndex = null;
            document.getElementById('incomingModalTitle').textContent = '添加进货记录';
            document.getElementById('incomingGoodsName').value = '';
            document.getElementById('incomingQuantity').value = '';
            document.getElementById('incomingTime').value = '';
            document.getElementById('incomingSupplier').value = '';
            document.getElementById('incomingModal').style.display = 'block';
        }

        function openEditIncomingModal(index) {
            currentIncomingIndex = index;
            let incoming = JSON.parse(localStorage.getItem('incoming'));
            let record = incoming[index];
            document.getElementById('incomingModalTitle').textContent = '编辑进货记录';
            document.getElementById('incomingGoodsName').value = record.goodsName;
            document.getElementById('incomingQuantity').value = record.quantity;
            document.getElementById('incomingTime').value = record.time;
            document.getElementById('incomingSupplier').value = record.supplier;
            document.getElementById('incomingModal').style.display = 'block';
        }

        function closeIncomingModal() {
            document.getElementById('incomingModal').style.display = 'none';
        }

        function saveIncoming() {
            let incoming = JSON.parse(localStorage.getItem('incoming')) || [];
            let goodsName = document.getElementById('incomingGoodsName').value;
            let quantity = parseInt(document.getElementById('incomingQuantity').value);
            let time = document.getElementById('incomingTime').value;
            let supplier = document.getElementById('incomingSupplier').value;
            if (currentIncomingIndex === null) {
                incoming.push({ goodsName, quantity, time, supplier });
            } else {
                incoming[currentIncomingIndex] = { goodsName, quantity, time, supplier };
            }
            localStorage.setItem('incoming', JSON.stringify(incoming));
            initTables();
            closeIncomingModal();
        }

        function deleteIncoming(index) {
            let incoming = JSON.parse(localStorage.getItem('incoming')) || [];
            incoming.splice(index, 1);
            localStorage.setItem('incoming', JSON.stringify(incoming));
            initTables();
        }

        // 出货管理
        function openAddOutgoingModal() {
            currentOutgoingIndex = null;
            document.getElementById('outgoingModalTitle').textContent = '添加出货记录';
            document.getElementById('outgoingGoodsName').value = '';
            document.getElementById('outgoingQuantity').value = '';
            document.getElementById('outgoingTime').value = '';
            document.getElementById('outgoingCustomer').value = '';
            document.getElementById('outgoingModal').style.display = 'block';
        }

        function openEditOutgoingModal(index) {
            currentOutgoingIndex = index;
            let outgoing = JSON.parse(localStorage.getItem('outgoing'));
            let record = outgoing[index];
            document.getElementById('outgoingModalTitle').textContent = '编辑出货记录';
            document.getElementById('outgoingGoodsName').value = record.goodsName;
            document.getElementById('outgoingQuantity').value = record.quantity;
            document.getElementById('outgoingTime').value = record.time;
            document.getElementById('outgoingCustomer').value = record.customer;
            document.getElementById('outgoingModal').style.display = 'block';
        }

        function closeOutgoingModal() {
            document.getElementById('outgoingModal').style.display = 'none';
        }

        function saveOutgoing() {
            let outgoing = JSON.parse(localStorage.getItem('outgoing')) || [];
            let goodsName = document.getElementById('outgoingGoodsName').value;
            let quantity = parseInt(document.getElementById('outgoingQuantity').value);
            let time = document.getElementById('outgoingTime').value;
            let customer = document.getElementById('outgoingCustomer').value;
            if (currentOutgoingIndex === null) {
                outgoing.push({ goodsName, quantity, time, customer });
            } else {
                outgoing[currentOutgoingIndex] = { goodsName, quantity, time, customer };
            }
            localStorage.setItem('outgoing', JSON.stringify(outgoing));
            initTables();
            closeOutgoingModal();
        }

        function deleteOutgoing(index) {
            let outgoing = JSON.parse(localStorage.getItem('outgoing')) || [];
            outgoing.splice(index, 1);
            localStorage.setItem('outgoing', JSON.stringify(outgoing));
            initTables();
        }

        // 供应商管理
        function openAddSupplierModal() {
            currentSupplierIndex = null;
            document.getElementById('supplierModalTitle').textContent = '添加供应商';
            document.getElementById('supplierName').value = '';
            document.getElementById('supplierContact').value = '';
            document.getElementById('supplierModal').style.display = 'block';
        }

        function openEditSupplierModal(index) {
            currentSupplierIndex = index;
            let suppliers = JSON.parse(localStorage.getItem('suppliers'));
            let supplier = suppliers[index];
            document.getElementById('supplierModalTitle').textContent = '编辑供应商';
            document.getElementById('supplierName').value = supplier.name;
            document.getElementById('supplierContact').value = supplier.contact;
            document.getElementById('supplierModal').style.display = 'block';
        }

        function closeSupplierModal() {
            document.getElementById('supplierModal').style.display = 'none';
        }

        function saveSupplier() {
            let suppliers = JSON.parse(localStorage.getItem('suppliers')) || [];
            let name = document.getElementById('supplierName').value;
            let contact = document.getElementById('supplierContact').value;
            if (currentSupplierIndex === null) {
                suppliers.push({ name, contact });
            } else {
                suppliers[currentSupplierIndex] = { name, contact };
            }
            localStorage.setItem('suppliers', JSON.stringify(suppliers));
            initTables();
            closeSupplierModal();
        }

        function deleteSupplier(index) {
            let suppliers = JSON.parse(localStorage.getItem('suppliers')) || [];
            suppliers.splice(index, 1);
            localStorage.setItem('suppliers', JSON.stringify(suppliers));
            initTables();
        }

        // 搜索功能
        function searchGoods() {
            let input = document.getElementById('goodsSearch');
            let filter = input.value.toUpperCase();
            let table = document.getElementById('goodsTable');
            let tr = table.getElementsByTagName('tr');
            for (let i = 1; i < tr.length; i++) {
                let td = tr[i].getElementsByTagName('td')[0];
                if (td) {
                    let txtValue = td.textContent || td.innerText;
                    if (txtValue.toUpperCase().indexOf(filter) > -1) {
                        tr[i].style.display = '';
                    } else {
                        tr[i].style.display = 'none';
                    }
                }
            }
        }

        function searchIncoming() {
            let input = document.getElementById('incomingSearch');
            let filter = input.value.toUpperCase();
            let table = document.getElementById('incomingTable');
            let tr = table.getElementsByTagName('tr');
            for (let i = 1; i < tr.length; i++) {
                let td = tr[i].getElementsByTagName('td')[0];
                if (td) {
                    let txtValue = td.textContent || td.innerText;
                    if (txtValue.toUpperCase().indexOf(filter) > -1) {
                        tr[i].style.display = '';
                    } else {
                        tr[i].style.display = 'none';
                    }
                }
            }
        }

        function searchOutgoing() {
            let input = document.getElementById('outgoingSearch');
            let filter = input.value.toUpperCase();
            let table = document.getElementById('outgoingTable');
            let tr = table.getElementsByTagName('tr');
            for (let i = 1; i < tr.length; i++) {
                let td = tr[i].getElementsByTagName('td')[0];
                if (td) {
                    let txtValue = td.textContent || td.innerText;
                    if (txtValue.toUpperCase().indexOf(filter) > -1) {
                        tr[i].style.display = '';
                    } else {
                        tr[i].style.display = 'none';
                    }
                }
            }
        }

        function searchSupplier() {
            let input = document.getElementById('supplierSearch');
            let filter = input.value.toUpperCase();
            let table = document.getElementById('supplierTable');
            let tr = table.getElementsByTagName('tr');
            for (let i = 1; i < tr.length; i++) {
                let td = tr[i].getElementsByTagName('td')[0];
                if (td) {
                    let txtValue = td.textContent || td.innerText;
                    if (txtValue.toUpperCase().indexOf(filter) > -1) {
                        tr[i].style.display = '';
                    } else {
                        tr[i].style.display = 'none';
                    }
                }
            }
        }

        // 页面加载完成后初始化表格
        window.onload = function () {
            initTables();
            openTab(event, 'Home');
        };
    </script>
</body>

</html>
